
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>三鑫灯世界 - 购物车</title>
    <link rel="stylesheet" href="__PUBLIC__/css/c.css">
    <link rel="stylesheet" href="__PUBLIC__/css/carts.css">
    <script src="__PUBLIC__/js/jquery-1.8.3.min.js"></script>
    <script src="__PUBLIC__/js/carts.js"></script>
    <style>
        #show{display: none; position: absolute; top: 200px; left: 22%; width: 53%; height: 49%; padding: 8px; border: 8px solid #E8E9F7; background-color: white; z-index:1002; overflow: auto;}
    </style>
</head>
<body>
	<!--公共头部2-->
    <include file="Public:head2"/>

    <section class="cartMain" style="text-align: center">
        <div class="cartMain_hd">
            <ul class="order_lists cartTop">
                <li class="list_chk">
                    <!--所有商品全选-->
                    <input type="checkbox" id="all" class="whole_check" autocomplete="off">
                    <label for="all"></label>
                    全选
                </li>
                <li class="" style="width:100px">商品图片</li>
                <li class="" style="width:180px">商品名称</li>
                <li class="list_info">商品参数</li>
                <if condition="session('user_vip') eq 1">
                    <li class="list_price">会员价</li>
                <else />
                    <li class="list_price">单价</li>
                </if>
                <li class="list_amount">数量</li>
                <li class="list_amount">运费</li>
                <li class="list_sum">小计</li>
                <li class="list_op">操作</li>
                
            </ul>
        </div>

        <div class="cartBox">            
            <div class="order_content">
                <volist name="list" id="li" key="v">
                    <ul class="order_lists">
                        <li class="list_chk">
                            <input type="checkbox" id="checkbox_{$v}" value="{$li.cart_id}" class="son_check" autocomplete="off">
                            <label for="checkbox_{$v}"></label>
                        </li>

                        <li class="" style="width:130px;text-align: right">
                            <div style="margin-top: 20px;line-height: 18px;"><a href="javascript:;"><img src="__ROOT__{$li.picture}" style="width: 80%"></a></div>
                        </li>
                        <li class=""  style="width:180px">
                            <div style="margin-top: 20px;line-height: 18px;"><a href="javascript:;">{$li.good_name}</a></div>
                        </li>
                        <li class="list_info">
                            <p>{$li.grade}</p>
                        </li>
                        <if condition="session('user_vip') eq 1">
                            <li class="list_price">
                                <p class="price">￥{$li.vip_price}</p>
                            </li>
                        <else />
                            <li class="list_price">
                                <p class="price">￥{$li.price}</p>
                            </li>
                        </if>
                        <li class="list_amount" style="text-align: -webkit-center;text-align: -moz-center;">
                            <div class="amount_box">
                                <input type="hidden" value="{$li.cart_id}" class="cartId">
                                <a href="javascript:;" class="reduce reSty " onclick="minusre($(this))">-</a>
                                <input type="text" value="{$li.goods_num}" class="sum">
                                <a href="javascript:;" class="plus">+</a>
                            </div>
                        </li>
                        <li class="list_amount">
                            <p style="color:red;margin-top: 20px;"><b>包邮</b></p>
                        </li>
                        <li class="list_sum">
                            <p class="sum_price"></p>
                        </li>
                        <li class="list_op">
                            <p class="del" attr="{$li.cart_id}"><a href="javascript:;" class="">移除商品</a></p>
                        </li>
                    </ul>
                </volist>

            </div>
        </div>

        <!--底部-->
        <div class="bar-wrapper">
            <div class="bar-right">
                <div class="piece">已选商品<strong class="piece_num">0</strong>件</div>
                <div class="totalMoney">共计: <strong class="total_text">0.00</strong></div>
                <div class="calBtn" onclick="jiesuan()"><a href="javascript:;" id="suan">结算</a></div>
            </div>
        </div>
    </section>
    <section class="model_bg"></section>

    <!--公共底部-->
    <include file="Public:footer"/>

    <script>
        $(function () {
            $('.price').each(function () {

                $(this).parent().parent().find(".sum_price").text("￥"+Number(Number($(this).text().substring(1))*$(this).parent().parent().find(".sum").val()).toFixed(2))
            })


        })
    </script>
    <script>
        //购物车删除商品
        $('.del').click(function () {
            var cart_id = $(this).attr('attr');
            var $aaa = $(this);
            $.ajax({
                url:"{:U('cart_del')}",
                data:{'cart_id':cart_id},
                type:'post',
                success:function(e){
                    if(e == 1){
                        $aaa.parent().parent().remove();
                    }
                }
            })
        })

        //修改购物车商品数量
        $('.plus').click(function () {
            var cartId = $(this).parent().find('.cartId').val();
            $.ajax({
                url:"{:U('cart_save')}",
                data:{'cart_id':cartId,'type':'jia'},
                type:'post',
                success:function(e){

                }
            })
        })
        function minusre(t) {
                var cartId = t.parent().find('.cartId').val();
                $.ajax({
                    url:"{:U('cart_save')}",
                    data:{'cart_id':cartId,'type':'jian'},
                    type:'post',
                    success:function(e){
                    }
                })
        }

        //结算
        function jiesuan() {
            if($('#suan').is('.btn_sty')){
                var cid="";
                var sumid = "";
                $('.order_lists').find('.son_check:checked').each(function () {
                    cid += $(this).val()+',';
                });
                $('.sum').each(function () {
                    if($(this).parents('.order_lists').find('.son_check').is(':checked')){
                        sumid += $(this).val()+',';
                    }
                });
                $('.calBtn a').attr('href',"{:U('confirmOrder')}?cid="+cid+"&sumid="+sumid);
            }
        }
    </script>

    <script type="text/javascript">
        //后退强制刷新
        if(window.name != "bencalie"){
            location.reload();
            window.name = "bencalie";
        }else{
            window.name = "";
        }
    </script>

    <!--固定底部-->
    <if condition="$cart_num lt 3">
        <script>
            $('.pingpu-bg').addClass('footer_fixed')
        </script>
    </if>
</body>
</html>